﻿using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

namespace JQMergeFramework
{
    public class UIMsgTips:MonoBehaviour
    {
        public BhvEasyPool tipsPool;

        public void ShowMsg(string msg)
        {
           GameObject obj = tipsPool.Get();
           obj.transform.DOKill();
           
           CanvasGroup cg = obj.GetComponent<CanvasGroup>();
           cg.alpha = 1;
           
           Sequence sq = DOTween.Sequence();
           obj.transform.localPosition = Vector3.zero;

           sq.Append(obj.transform.DOLocalMoveY(200, 1F));
           sq.Join(cg.DOFade(0.2F, 1));
           sq.OnComplete(() =>
           {
               tipsPool.Put(obj);
           });
           sq.Play();
           
           obj.GetComponentInChildren<Text>().text = msg;
        }
    }
}